# -*- coding: utf-8 -*-
'''
@author: olivia.dou
Created on: 2020/9/13 16:13
desc:
'''
import logging
import pandas as pd
#pd.set_option("xlsx", "openpyxl")
import base.globalvars as glo
from base.get_config import get_data_file
from proj_spec.DAS.po.login_po import *


def login(driver,account_type,user_identity):
    """

    :param driver: webdriver对象
    :param account_type: 账号类型：0-LDAP，1-Standard
    :param user_identity: 用户识别名，在数据文件中可找到相应的用户名/密码

    :return: 无
    """
    try:
        #users = pd.read_excel(get_data_file(),dtype='str')
        users = pd.read_excel(get_data_file(),dtype='str',engine = "openpyxl")
        username = list(users[users['user_identity']==user_identity]['username'])[0]
        password = list(users[users['user_identity'] == user_identity]['password'])[0]

        lp = LoginPage(driver, glo.get_value('url1'))
        lp.login(account_type, username, password)
    except Exception as e:
        logging.error("login fail: %s"%e)
 